# get请求与post请求的区别：
# 1. get请求的参数在url中，post请求的参数在请求体中
import requests

url = "http://www.httpbin.org/post"
data = {"name":"zhangsan","age":18}
# content-type:application/json   json
# content-type:application/x-www-form-urlencoded  data
# content-type:multipart/form-data  files

with open("baidu.jpg","rb") as f:
    files = {"file":f}
    response = requests.post(url,files=files)
    print("状态码：",response.status_code)  # 405请求方法类型有问题
    print(response.content.decode())

# 原始报文结构
'''
POST http://www.httpbin.org/post HTTP/1.1\r\n
Accept:*/*\r\n
Accept-Encoding:gzip, deflate\r\n
Accept-Language:zh-CN,zh;q=0.9\r\n
Connection:keep-alive\r\n
Content-Type:application/x-www-form-urlencoded\r\n
Content-Type:application/json\r\n
\r\n
name=zhangsan&age=18
{"age": 18, "name": "zhangsan"}
'''